#!/bin/sh
echo ">>>>>>>STEP 1>>>>>>>"
cat /etc/hosts
ls -al
cat /root/.git-credentials
cat /root/.gitconfig
echo "************git clone -b ${TAG} ${REMOTE_URL}****************"
git clone -b $TAG $REMOTE_URL
cd  $PROJECT_NAME
ls -al
echo "************clone end****************"

echo ">>>>>>>STEP 2>>>>>>>"
echo "************faas build -f $BUILD_FILE_YML****************"
docker_remote_host=tcp://192.168.1.250 TAG=${TAG} /home/app/faas-cli-cc build -f $BUILD_FILE_YML
echo "************build end****************"

echo ">>>>>>>STEP 3"
echo "************login docker****************"
docker -H tcp://192.168.1.250 login --password $DOCKER_HUB_PWD --username $DOCKER_HUB_USER harbor.junengcloud.com
echo "************end****************"

echo ">>>>>>>STEP 4>>>>>>>"
echo "************begin push ${IMAGE_NAME}:${TAG} ****************"
docker -H tcp://192.168.1.250 push ${IMAGE_NAME}:${TAG}
echo "************end   push****************"

echo ">>>>>>>STEP 5>>>>>>>"
echo "************deploy push****************"
OPENFAAS_URL=${OPENFAAS_URL}
echo ${OPENFAAS_PWD} | /home/app/faas-cli-cc login -u admin --password-stdin
TAG=${TAG} FAAS_ENV=${FAAS_ENV} /home/app/faas-cli-cc deploy -f $BUILD_FILE_YML
echo "************end   deploy****************"
top
